<?php
/**
 * #Celebrate Shieh
 *             ,%%%%%%%%,
 *           ,%%/\%%%%/\%%
 *          ,%%%\c "" J/%%%
 * %.       %%%%/ o  o \%%%
 * `%%.     %%%%    _  |%%%
 *  `%%     `%%%%(__Y__)%%'
 *  //       ;%%%%`\-/%%%'
 * ((       /  `%%%%%%%'
 *  \\    .'          |
 *   \\  /       \  | |
 *    \\/         ) | |
 *     \         /_ | |__
 *     (___________))))))) 攻城湿
 *
 *        _       _
 * __   _(_)_   _(_) __ _ _ __
 * \ \ / / \ \ / / |/ _` |'_ \
 *  \ V /| |\ V /| | (_| | | | |
 *   \_/ |_| \_/ |_|\__,_|_| |_|
 */

namespace App\Modules\Blog\Http\Controllers;


use Illuminate\Http\Request;


class NoticeController extends Controller
{

    /**
     * 获取公告
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function index( Request $request )
    {
        return $this->getNotice()->NoticeIndexService($request);
    }

    /**
     * 新增公告
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function create( Request $request )
    {
        return $this->getNotice()->NoticeCreateService($request);
    }

    /**
     * 公告修改状态
     *
     * @param Request $request
     * @param         $id
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function is_show( Request $request, $id )
    {
        request()->offsetSet('id', $id);
        return $this->getNotice()->NoticeIsShowService($request);
    }

    /**
     * 获取公告详情
     *
     * @param $id
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function show( $id )
    {
        return $this->getNotice()->NoticeShowService($id);
    }

    /**
     * 修改公告
     *
     * @param Request $request
     * @param         $id
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function update( Request $request, $id )
    {
        request()->offsetSet('id', $id);
        return $this->getNotice()->NoticeUpdateService($request);
    }

    /**
     * 删除公告
     *
     * @param         $id
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function destroy( $id )
    {
        return $this->getNotice()->NoticeDestroyService($id);
    }

    /**
     * 删除公告
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function delete( Request $request )
    {
        return $this->getNotice()->NoticeDestroyService($request->input('id', []));
    }
}
